﻿using System.Data;
using System.Data.SqlTypes;
using System.Data.SqlClient;
using System.Text;
using ECommerce.DAL;


namespace Entity
{
    /// <summary>
    /// This class provides extension methods for TblGiftCertificate.
    /// </summary>

    public partial class TblGiftCertificate : DatabaseUtility
    {
        public static TblGiftCertificate GetGiftCertificateByCode(string GiftCertificateCode)
        {
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@Code", SqlDbType.VarChar, 20, ParameterDirection.Input, GiftCertificateCode);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, "spr_GiftCertificate_GetGiftCertificateByCode");
            GenerateCollectionFromReader test = new GenerateCollectionFromReader(TblGiftCertificate.GenerateTblGiftCertificateCollectionFromReader);
            CustomCollection<TblGiftCertificate> objCollection = ((CustomCollection<TblGiftCertificate>)ExecuteReaderCmd(sqlCmd, test));

            if (objCollection.Count > 0)
                return objCollection[0];
            else
                return null;

        }
    }
}
